home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / spiders.c < prev    next >
C/C++ Source or Header  |  2000-03-04  |  15KB  |  429 lines

  1. /***************************************************************************
  2.  
  3. Spiders driver by K.Wilkins May 1998
  4.  
  5.  
  6. Memory map information
  7. ----------------------
  8.  
  9. Main CPU - Read Range
  10.  
  11. $0000-$1bff    Video Memory (bit0)
  12. $4000-$5bff    Video Memory (bit1)
  13. $8000-$9bff    Video Memory (bit2)
  14. $c000-$c001    6845 CRT Controller (crtc6845)
  15. $c044-$c047    MC6821 PIA 1 (Control input port - all input)
  16. $c048-$c04b    MC6821 PIA 2 (Sprite data port - see machine/spiders.c)
  17. $c050-$c053    MC6821 PIA 3 (Sound control - all output)
  18. $c060        Dip Switch 1
  19. $c080        Dip Switch 2
  20. $c0a0        Dip Switch 3
  21. $c100-ffff    ROM SPACE
  22.  
  23. Main CPU - Write Range
  24.  
  25. $0000-$1bff    Video Memory (bit0)
  26. $4000-$5bff    Video Memory (bit1)
  27. $8000-$9bff    Video Memory (bit2)
  28. $c000-$c001    6845 CRT Controller (crtc6845)
  29. $c044-$c047    MC6821 PIA 1
  30. $c048-$c04b    MC6821 PIA 2 (Video port)
  31. $c050-$c053    MC6821 PIA 3
  32.  
  33.  
  34. DIP SWITCH 1
  35. ------------
  36.  
  37.    1   2   3   4   5   6   7   8    COIN/CREDIT
  38.    ON  ON  ON                       FREE PLAY
  39.    ON  ON  OFF                      1/2
  40.    ON  OFF ON                       1/3
  41.    OFF ON  ON                       2/1
  42.    ON  OFF OFF                      4/5
  43.    OFF OFF OFF                      1/1
  44.  
  45. DIP SWITCH 2
  46. ------------
  47.  
  48.    1   2   3   4   5   6   7   8
  49.    ON  ON                           MODE A    A'
  50.    ON  OFF                               A    B'
  51.    OFF ON                                B    A'
  52.    OFF OFF                               B    B'
  53.            ON  ON                   14 # OF SPIDERS WHICH LAND TO
  54.            ON  OFF                  20    COMPLETE SPIDER BELT
  55.            OFF ON                   26
  56.            OFF OFF                  16
  57.                    ON               4  # 0F SPARE GUNS
  58.                    OFF              3
  59.                        ON   ON      NONE  SCORE FOR BONUS GUN
  60.                        ON   OFF     20K
  61.                        OFF  ON      25K
  62.                        OFF  OFF     15K
  63.                                ON   GIANT SPIDER AFTER FIRST SCREEN
  64.                                OFF  GIANT SPIDER AFTER EVERY SCREEN
  65.  
  66.    PATTERN   1   2   3   4   5   6   7   8   9   10  11  12  13  14
  67.    MODE A    27  36  45  54  63  72  81  98  45  54  63  72  81  98    PCS
  68.    MODE B    20  27  34  41  48  55  62  69  34  41  48  55  62  69    PCS
  69.    MODE A'   1   1   1   3.5 3.5 4   4.5 5   1   3.5 3.5 4   4.5 5     SECONDS
  70.    MODE B'   .7  .7  .7  2   3   3.2 3.4 4   .7  2   3   2.3 3.4 4     SECONDS
  71.  
  72.    MODE A & B FOR THE NUMBER OF GROWABLE COCOONS
  73.    MODE A' & B' FOR THE FREQUENCY OF SPIDERS APPEARANCE
  74.  
  75.  
  76. DIP SWITCH 3
  77. ------------
  78.  
  79.    1   2   3   4   5   6   7   8
  80.    X                                VIDEO FLIP
  81.        ON                           UPRIGHT
  82.        OFF                          TABLE
  83.  
  84.    SWITCHES 3,4,5 FOR ADJUSTING PICTURE VERTICALLY
  85.    SWITCHES 6,7,8 FOR ADJUSTING PICTURE HORIZONTALLY
  86.  
  87.  
  88. Unpopulated Switches
  89. --------------------
  90.  
  91.   PS1 (Display Crosshatch)         - Connected to PIA1 CB1 via pull-up
  92.   PS2 (Coin input, bypass counter) - Connected to PIA1 PA1 via pull-up and invertor
  93.   PS3 (Display coin counter)       - Connected to PIA1 PA2 via pull-up and invertor
  94.  
  95.  
  96. Graphic notes
  97. -------------
  98. Following roms appear to have graphic data
  99.  
  100. * Mapped in main CPU space
  101.  
  102. * SP1.BIN    - Appears to have some sprites in it.
  103. * SP2.BIN    - Appears to have some 16x16 sprites. (Includes the word SIGMA)
  104. * SP3.BIN    - Appears to have 2-4 sprites 16x16 - spiders
  105. * SP4.BIN    - CPU Code 6809 - Main
  106.   SP5.BIN    - Some 8x8 and 16x16 tiles/sprites
  107.   SP6.BIN    - Some 8x8 tiles
  108.   SP7.BIN    - Tiles/Sprites 8x8
  109.   SP8.BIN    - Tiles/Sprites 8x8
  110.   SP9A.BIN     - Tiles/Sprites 8x8
  111.   SP9B.BIN    - Tiles/Sprites 8x8
  112.   SP10A.BIN    - Tiles/Sprites 8x8
  113.   SP10B.BIN    - CPU Code 6802 - Sound
  114.  
  115. Spiders has a fully bitmapped display and all sprite drawing is handled by the CPU
  116. hence no gfxdecode is done on the sprite ROMS, the CPU accesses them via PIA2.
  117.  
  118. Screen is arranged in three memory areas with three bits being combined from each
  119. area to produce a 3bit colour send directly to the screen.
  120.  
  121. $0000-$1bff, $4000-$5bff, $8000-$9bff     Bank 0
  122. $2000-$3bff, %6000-$7bff, $a000-$bbff    Bank 1
  123.  
  124. The game normally runs from bank 0 only, but when lots of screen changes are required
  125. e.g spider or explosion then it implements a double buffered scheme with bank 1.
  126.  
  127. The ram bank for screens is continuous from $0000-$bfff but is physically arranged
  128. as 3 banks of 16k (8x16k DRAM!). The CPU stack/variables etc are stored in the unused
  129. spaces between screens.
  130.  
  131.  
  132. CODE NOTES
  133. ----------
  134.  
  135. 6809 Data page = $1c00 (DP=1c)
  136.  
  137. Known data page contents
  138. $05 - Dip switch 1 copy
  139. $06 - Dip switch 2 copy (inverted)
  140. $07 - Dip switch 3 copy
  141. $18 - Bonus Gun Score
  142. $1d - Spiders to complete belt after dipsw decode
  143.  
  144.  
  145. $c496 - Wait for vblank ($c04a bit 7 goes high)
  146. $f9cf - Clear screen (Bank0&1)
  147. $c8c6 - RAM test of sorts, called from IRQ handler?
  148. $de2f - Delay loop.
  149. $f9bb - Memory clearance routine
  150. $c761 - Partial DipSW decode
  151. $F987 - Addresses table at $f98d containing four structs:
  152.             3c 0C 04 0D 80 (Inverted screen bank 0)
  153.             34 0C 00 0D 00 (Normal screen   bank 0)
  154.             3C 0C 40 0D 80 (Inverted screen bank 1)
  155.             34 0C 44 0D 00 (Inverted screen bank 1)
  156.             XX             Written to PIA2 Reg 3 - B control
  157.                XX XX       Written to CRTC addr/data
  158.                      XX XX Written to CRTC addr/data
  159.             These tables are used for frame flipping
  160.  
  161.  
  162. ***************************************************************************/
  163.  
  164. #include "driver.h"
  165. #include "vidhrdw/generic.h"
  166. #include "vidhrdw/crtc6845.h"
  167. #include "machine/6821pia.h"
  168.  
  169.  
  170. /* VIDHRDW */
  171.  
  172. int  spiders_vh_start(void);
  173. void spiders_vh_stop(void);
  174. void spiders_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  175.  
  176. /* MACHINE */
  177.  
  178. void spiders_init_machine(void);
  179. int spiders_timed_irq(void);
  180.  
  181.  
  182. /* Driver structure definition */
  183.  
  184. static struct MemoryReadAddress readmem[] =
  185. {
  186.     { 0x0000, 0xbfff, MRA_RAM },
  187. //    { 0x1c00, 0x1cff, MRA_RAM },    // Data page
  188. //    { 0x4000, 0x5bff, MRA_RAM },    // Video ram 1
  189. //    { 0x8000, 0x9bff, MRA_RAM },    // Video ram 2
  190. //    { 0x7800, 0x7fff, MRA_RAM },    // Stack space
  191.     { 0xc001, 0xc001, crtc6845_register_r },
  192.     { 0xc044, 0xc047, pia_0_r },
  193.     { 0xc048, 0xc04b, pia_1_r },
  194.     { 0xc050, 0xc053, pia_2_r },
  195.     { 0xc060, 0xc060, input_port_2_r },
  196.     { 0xc080, 0xc080, input_port_3_r },
  197.     { 0xc0a0, 0xc0a0, input_port_4_r },
  198.     { 0xc100, 0xffff, MRA_ROM },
  199.     { -1 } /* end of table */
  200. };
  201.  
  202. static struct MemoryWriteAddress writemem[] =
  203. {
  204.     { 0x0000, 0xbfff, MWA_RAM },
  205. //    { 0x1c00, 0x1cff, MWA_RAM },
  206. //    { 0x4000, 0x5bff, MWA_RAM },
  207. //    { 0x8000, 0x9bff, MWA_RAM },
  208. //    { 0x7800, 0x7fff, MWA_RAM },
  209.     { 0xc000, 0xc000, crtc6845_address_w },
  210.     { 0xc001, 0xc001, crtc6845_register_w },
  211.     { 0xc044, 0xc047, pia_0_w },
  212.     { 0xc048, 0xc04b, pia_1_w },
  213.     { 0xc050, 0xc053, pia_2_w },
  214.     { 0xc100, 0xffff, MWA_ROM },
  215.     { -1 } /* end of table */
  216. };
  217.  
  218.  
  219. #if 0
  220. static struct MemoryReadAddress sound_readmem[] =
  221. {
  222.     { 0x0000, 0x007f, MRA_RAM },
  223.     { 0xf800, 0xffff, MRA_ROM },
  224.     { -1 }  /* end of table */
  225. };
  226.  
  227. static struct MemoryWriteAddress sound_writemem[] =
  228. {
  229.     { 0x0000, 0x007f, MWA_RAM },
  230.     { 0xf800, 0xffff, MWA_ROM },
  231.     { -1 }  /* end of table */
  232. };
  233. #endif
  234.  
  235.  
  236. INPUT_PORTS_START( spiders )
  237.     PORT_START      /* IN0 */
  238.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
  239.     PORT_BITX(0x02, 0x00, IP_ACTIVE_HIGH , "PS2 (Operator coin)", KEYCODE_4, IP_JOY_NONE )
  240.     PORT_BITX(0x04, 0x00, IP_ACTIVE_HIGH , "PS3 (Coin Counter)", KEYCODE_F1, IP_JOY_NONE )
  241.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 )
  242.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
  243.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
  244.     PORT_BIT( 0x90, IP_ACTIVE_HIGH, IPT_UNUSED )
  245.  
  246.     PORT_START      /* IN1 */
  247.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_2WAY )
  248.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  249.     PORT_BIT( 0xF3, IP_ACTIVE_HIGH, IPT_UNUSED )
  250.  
  251.     PORT_START  /* DSW1 */
  252.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
  253.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  254.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
  255.     PORT_DIPSETTING(    0x06, DEF_STR( 4C_5C ) )
  256.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
  257.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
  258.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  259.     PORT_BIT(0xf8, IP_ACTIVE_LOW,IPT_UNUSED)
  260.  
  261.     PORT_START  /* DSW2 */
  262.     PORT_DIPNAME( 0x03, 0x03, "Play mode" )
  263.     PORT_DIPSETTING(    0x00, "A A'" )
  264.     PORT_DIPSETTING(    0x01, "A B'" )
  265.     PORT_DIPSETTING(    0x02, "B A'" )
  266.     PORT_DIPSETTING(    0x03, "B B'" )
  267.     PORT_DIPNAME( 0x0c, 0x0c, "Spiders to complete belt" )
  268.     PORT_DIPSETTING(    0x00, "14" )
  269.     PORT_DIPSETTING(    0x04, "20" )
  270.     PORT_DIPSETTING(    0x08, "26" )
  271.     PORT_DIPSETTING(    0x0c, "16" )
  272.     PORT_DIPNAME( 0x10, 0x10, "Spare Guns" )
  273.     PORT_DIPSETTING(    0x00, "4" )
  274.     PORT_DIPSETTING(    0x10, "3" )
  275.     PORT_DIPNAME( 0x60, 0x60, "Score for bonus gun" )
  276.     PORT_DIPSETTING(    0x00, "NONE" )
  277.     PORT_DIPSETTING(    0x20, "20K" )
  278.     PORT_DIPSETTING(    0x40, "25K" )
  279.     PORT_DIPSETTING(    0x60, "15K" )
  280.     PORT_DIPNAME( 0x80, 0x00, "Giant Spiders" )
  281.     PORT_DIPSETTING(    0x00, "First screen" )
  282.     PORT_DIPSETTING(    0x80, "Every screen" )
  283.  
  284.     PORT_START  /* DSW3 */
  285.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) )
  286.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  287.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  288.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ) )
  289.     PORT_DIPSETTING(    0x02, DEF_STR( Upright ) )
  290.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  291.     PORT_DIPNAME( 0x1c, 0x00, "Vertical Adjust" )
  292.     PORT_DIPSETTING(    0x00, "0" )
  293.     PORT_DIPSETTING(    0x04, "1" )
  294.     PORT_DIPSETTING(    0x08, "2" )
  295.     PORT_DIPSETTING(    0x0c, "3" )
  296.     PORT_DIPSETTING(    0x10, "4" )
  297.     PORT_DIPSETTING(    0x14, "5" )
  298.     PORT_DIPSETTING(    0x18, "6" )
  299.     PORT_DIPSETTING(    0x1c, "7" )
  300.     PORT_DIPNAME( 0xe0, 0x00, "Horizontal Adjust" )
  301.     PORT_DIPSETTING(    0x00, "0" )
  302.     PORT_DIPSETTING(    0x20, "1" )
  303.     PORT_DIPSETTING(    0x40, "2" )
  304.     PORT_DIPSETTING(    0x60, "3" )
  305.     PORT_DIPSETTING(    0x80, "4" )
  306.     PORT_DIPSETTING(    0xa0, "5" )
  307.     PORT_DIPSETTING(    0xc0, "6" )
  308.     PORT_DIPSETTING(    0xe0, "7" )
  309.  
  310.     PORT_START      /* Connected to PIA1 CA1 input */
  311.     PORT_BIT( 0xFF, IP_ACTIVE_HIGH, IPT_VBLANK )
  312.  
  313.     PORT_START      /* Connected to PIA0 CB1 input */
  314.     PORT_BITX(0xff, 0xff, IP_ACTIVE_LOW, "PS1 (Crosshatch)", KEYCODE_F2, IP_JOY_NONE )
  315.  
  316. INPUT_PORTS_END
  317.  
  318.  
  319.  
  320. /* The bitmap RAM is directly mapped to colors, no PROM. */
  321. static unsigned char palette[] =
  322. {
  323.     0x00,0x00,0x00,
  324.     0xff,0x00,0x00,
  325.     0x00,0xff,0x00,
  326.     0xff,0xff,0x00,
  327.     0x00,0x00,0xff,
  328.     0xff,0x00,0xff,
  329.     0x00,0xff,0xff,
  330.     0xff,0xff,0xff,
  331. };
  332. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  333. {
  334.     memcpy(game_palette,palette,sizeof(palette));
  335. }
  336.  
  337.  
  338.  
  339. static struct MachineDriver machine_driver_spiders =
  340. {
  341.         /* basic machine hardware */
  342.     {
  343.         {
  344.             CPU_M6809,
  345.             2800000,
  346.             readmem,writemem,0,0,
  347.             0,0,                     /* Vblank Int */
  348.             spiders_timed_irq , 25   /* Timed Int  */
  349.         },
  350. //        {
  351. //            CPU_M6802 | CPU_AUDIO_CPU,
  352. //            3000000/4,
  353. //            1,
  354. //            sound_readmem,sound_writemem,0,0,
  355. //            0,0,
  356. //            0,0
  357. //        }
  358.     },
  359.     60,
  360.     DEFAULT_REAL_60HZ_VBLANK_DURATION,
  361.     10,     /* 10 CPU slices per frame - enough for the sound CPU to read all commands */
  362.     spiders_init_machine,
  363.  
  364.     /* video hardware */
  365.     32*8, 28*8,                         /* Width/Height         */
  366.     { 0*8, 32*8-1, 0*8, 28*8-1 },       /* Visible area         */
  367.     0,
  368.     sizeof(palette) / sizeof(palette[0]) / 3, 0,
  369.     init_palette,
  370.  
  371.     VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY,                  /* Video attributes     */
  372.     0,                                  /* Video initialisation */
  373.     spiders_vh_start,                    /* Video start          */
  374.     spiders_vh_stop,                     /* Video stop           */
  375.     spiders_vh_screenrefresh,                   /* Video update         */
  376.  
  377.     /* sound hardware */
  378.     0,0,0,0
  379.     /* Sound struct here */
  380. };
  381.  
  382.  
  383.  
  384. ROM_START( spiders )
  385.     ROM_REGION( 0x10000, REGION_CPU1 )
  386.     ROM_LOAD( "sp-ic74",      0xc000, 0x1000, 0x6a2578f6 )
  387.     ROM_LOAD( "sp-ic73",      0xd000, 0x1000, 0xd69b2f21 )
  388.     ROM_LOAD( "sp-ic72",      0xe000, 0x1000, 0x464125da )
  389.     ROM_LOAD( "sp-ic71",      0xf000, 0x1000, 0xa9539b18 )
  390.  
  391.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for the audio CPU */
  392.     ROM_LOAD( "sp-ic3",       0xf800, 0x0800, 0x944d761e )
  393.  
  394.     ROM_REGION( 0x10000, REGION_GFX1 )     /* 64k graphics block used at runtime */
  395.     ROM_LOAD( "sp-ic33",      0x0000, 0x1000, 0xb6731baa )
  396.     ROM_LOAD( "sp-ic25",      0x1000, 0x1000, 0xbaec64e7 )
  397.     ROM_LOAD( "sp-ic24",      0x2000, 0x1000, 0xa40a5517 )
  398.     ROM_LOAD( "sp-ic23",      0x3000, 0x1000, 0x3ca08053 )
  399.     ROM_LOAD( "sp-ic22",      0x4000, 0x1000, 0x07ea073c )
  400.     ROM_LOAD( "sp-ic21",      0x5000, 0x1000, 0x41b344b4 )
  401.     ROM_LOAD( "sp-ic20",      0x6000, 0x1000, 0x4d37da5a )
  402. ROM_END
  403.  
  404. ROM_START( spiders2 )
  405.     ROM_REGION( 0x10000, REGION_CPU1 )
  406.     ROM_LOAD( "sp-ic74",      0xc000, 0x1000, 0x6a2578f6 )
  407.     ROM_LOAD( "sp2.bin",      0xd000, 0x1000, 0xcf71d12b )
  408.     ROM_LOAD( "sp-ic72",      0xe000, 0x1000, 0x464125da )
  409.     ROM_LOAD( "sp4.bin",      0xf000, 0x1000, 0xf3d126bb )
  410.  
  411.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for the audio CPU */
  412.     ROM_LOAD( "sp-ic3",       0xf800, 0x0800, 0x944d761e )
  413.  
  414.     ROM_REGION( 0x10000, REGION_GFX1 )     /* 64k graphics block used at runtime */
  415.     ROM_LOAD( "sp-ic33",      0x0000, 0x1000, 0xb6731baa )
  416.     ROM_LOAD( "sp-ic25",      0x1000, 0x1000, 0xbaec64e7 )
  417.     ROM_LOAD( "sp-ic24",      0x2000, 0x1000, 0xa40a5517 )
  418.     ROM_LOAD( "sp-ic23",      0x3000, 0x1000, 0x3ca08053 )
  419.     ROM_LOAD( "sp-ic22",      0x4000, 0x1000, 0x07ea073c )
  420.     ROM_LOAD( "sp-ic21",      0x5000, 0x1000, 0x41b344b4 )
  421.     ROM_LOAD( "sp-ic20",      0x6000, 0x1000, 0x4d37da5a )
  422. ROM_END
  423.  
  424.  
  425.  
  426. /* this is a newer version with just one bug fix */
  427. GAMEX( 1981, spiders,  0,       spiders, spiders, 0, ROT270, "Sigma Ent. Inc.", "Spiders (set 1)", GAME_NO_SOUND | GAME_NO_COCKTAIL )
  428. GAMEX( 1981, spiders2, spiders, spiders, spiders, 0, ROT270, "Sigma Ent. Inc.", "Spiders (set 2)", GAME_NO_SOUND | GAME_NO_COCKTAIL )
  429.